home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
- From: Dan Pop <danpop@mail.cern.ch>
- Newsgroups: comp.lang.c
- Subject: Re: Limit on #bytes inside of struct?
- Date: Sat, 10 Feb 1996 01:53:41 +0100
- Organization: CERN European Lab for Particle Physics
- Message-ID: <9602100053.AA09863@dxmint.cern.ch>
- References: <4fgg7g$r36@cville-srv.wam.umd.edu>
- X-NNTP-Posting-Host: hpl3sn03.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
- X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
-
- jsquires@wam.umd.edu (jeffrey d squires) writes:
-
- >What I left out was that I tried to do this:
- >
- >#define NUM_PASSES 3
- >hist_type histogram[NUM_PASSES]; /* BIIIIIG MISTAKE */
-
- ??? I can't see any mistake here.
-
- >I tried to have the above example be simple, but it appears that I left
- >out the part that contained the problem. I guess that you can;t
- >declare an array with the size defined by #define. I had to do:
-
- Your guess is wrong.
-
- #define NUM_PASSES 3
- hist_type histogram[NUM_PASSES];
- and
- hist_type histogram[3];
-
- are perfectly equivalent (NUM_PASSES has already been replaced by 3 when
- the compiler actually parses the declaration, during translation phase 7).
-
- >hist_type * histogram;
- >histogram = .... malloc(NUM_PASSES * ......
- >
- >That worked, and my problem is solved. Thanks everyone for responding
-
- This is a red herring. The bug is still there, but you can't see its
- effect because you changed the memory allocation scheme and 'num' is no
- longer right after 'histogram'.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-